<?php
namespace Learn\Base;
//单例模式
trait Singleton
{
    protected static $_instance;
    final public static function getInstance($config = array())
    {
        if (!isset(self::$_instance)) {
            self::$_instance = new static($config);
        }
        return self::$_instance;
    }
    private function __construct($config)
    {
        $this->init($config);
    }
    protected function init()
    {
    }
    //防止反序列化
    final public function __wakeup()
    {
    }
    //防止克隆
    final public function __clone()
    {
    }
}
